Imports System.ComponentModel
Imports System.Web.Security
Imports System.Web.HttpContext

Public Class InstrumentNode
    Public Sub New(ByVal instrumentId As String)
        Me._instrumentId = instrumentId
        _questions = New IQuestionNodeCollection
    End Sub

    Public Name, Description, Instruction As String
    Public CreatedDate, LastUpdated As DateTime
    Public Locked As Boolean

    Private _instrumentId As String
    Private _questions As IQuestionNodeCollection
    Private _firstQuestionNode As IQuestionNode
    Public Const _currentNodeSession As String = "_Taker_CurrentNode"


    Public ReadOnly Property InstrumentID() As String
        Get
            Return _instrumentId
        End Get
    End Property

    Public ReadOnly Property Questions() As IQuestionNodeCollection
        Get
            Return _questions
        End Get
    End Property


    Public Property CurrentNode() As IQuestionNode
        Get
            Dim curNode As IQuestionNode = Current.Session(_currentNodeSession)
            If curNode Is Nothing Then
                curNode = Me.FirstQuestionNode
                Current.Session(_currentNodeSession) = curNode
            End If
            Return curNode
        End Get
        Set(ByVal value As IQuestionNode)
            Current.Session(_currentNodeSession) = value
        End Set
    End Property

    Public ReadOnly Property FirstQuestionNode() As IQuestionNode
        Get
            If _firstQuestionNode Is Nothing Then
                _firstQuestionNode = QuestionnaireTakerODS.Provider.FirstNodeTable(Me.InstrumentID)
            End If
            Return _firstQuestionNode
        End Get
    End Property

End Class
